CryptoJS = require "crypto-js"

# 校验密码
checkPassword = (req, res, next)->
  password = req.body?.password or req.params?.password
  # 如果有交易密码
  if password
    # 解密aes密码
    password = CryptoJS.AES.decrypt(password, "gfotc123456")
    password = password.toString(CryptoJS.enc.Utf8)
    if req.method == "POST"
      req.body?.password = password
    else
      req.query?.password = password
    return next()
  else
    return next()
module.exports.checkPassword = checkPassword